package dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import net.sf.json.JSONObject;
import util.database.DBHelper;

public class GetMenuDao {

	public static ArrayList<JSONObject> GetMenu(int menuId) throws ClassNotFoundException, SQLException {
		String sql = "select id,title,contents,url from document where menu_id='" + menuId + "' and visible=0 order by priority";
		ResultSet rSet = DBHelper.executeQuery(sql);
		ArrayList<JSONObject> menuList = new ArrayList<JSONObject>();

		while (rSet.next()) {
			JSONObject jobj = new JSONObject();
			jobj.put("id", rSet.getInt("id"));
			jobj.put("title", rSet.getString("title"));
			jobj.put("contents", rSet.getString("contents"));
			jobj.put("url", rSet.getString("url"));
			menuList.add(jobj);
		}
		return menuList;
	}
}
